package com.cxg.caiec.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.cxg.caiec.demo.R;
import com.cxg.fairy.delegates.FairyDelegate;
import com.cxg.fairy.net.RestClient;
import com.cxg.fairy.net.callback.IError;
import com.cxg.fairy.net.callback.IFailure;
import com.cxg.fairy.net.callback.ISuccess;

/**
 * Created by Administrator on 2017/10/20.
 */

public class ExampleDelegate extends FairyDelegate {

    @Override
    public Object setLayout() {
        return R.layout.delegate_example;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
//        testRestClient();
    }

    private void testRestClient() {
        RestClient.builder().url("http://127.0.0.1/index")
         .loader(getContext())
         .success(new ISuccess() {
            @Override
            public void onSuccess(String response) {
                Log.e("HAHHAHAAHHAHAHA", response);
                Toast.makeText(getContext(), response, Toast.LENGTH_LONG).show();
            }})
         .failure(new IFailure() {
            @Override
            public void onFailure() {

            }})
         .error(new IError() {
            @Override
            public void onError(int code, String msg) {
            }
        })
        .build()
        .get();
    }


}
